package com.waijiaojun.tpo.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {

    /**
     * yyyy-MM-dd hh:mm:ss
     */
    public static SimpleDateFormat sdf_1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

    /**
     * yyyyMMddhhmmss
     */
    public static SimpleDateFormat sdf_2 = new SimpleDateFormat("yyyyMMddhhmmss");

    /**
     * yyyy-MM-dd
     */
    public static SimpleDateFormat sdf_3 = new SimpleDateFormat("yyyy-MM-dd");

    /**
     * yyyyMMddhhmmssSSS
     */
    public static SimpleDateFormat sdf_4 = new SimpleDateFormat("yyyyMMddhhmmssSSS");

    public static String getTimeStamp() {
        Long ts = System.currentTimeMillis();
        ts = ts / 1000;
        return ts.toString();
    }

    public static int getDays(Date createDate) {
        Date now = new Date();
        int days = (int) Math.ceil((now.getTime() - createDate.getTime()) / (1000 * 3600 * 24));
        return days == 0 ? 1 : days;
    }
}
